import { NGradientText } from "naive-ui";
import type { BaseComponentType } from "../types";
import type { GradientTextProps } from "naive-ui";
import { getSlotsDom } from "../utils";
import type { HTMLAttributes } from "vue";
export type GradientTextFactoryConstructorType = {
  defaultSlot?: BaseComponentType;
  props?: GradientTextProps;
  attrs?: HTMLAttributes;
};
export class GradientTextFactory {
  private defaultSlot: BaseComponentType = null;
  private props: GradientTextProps = {};
  private attrs: HTMLAttributes = {};
  constructor(param?: GradientTextFactoryConstructorType) {
    if (param?.attrs) this.setAttrs(param.attrs);
    if (param?.props) this.setProps(param.props);
    if (param?.defaultSlot) this.setDefault(param.defaultSlot);
  }
  setDefault(component: BaseComponentType) {
    this.defaultSlot = component;
    return this;
  }
  setAttrs(attrs: HTMLAttributes) {
    this.attrs = attrs;
    return this;
  }
  setProps(props: GradientTextProps) {
    this.props = props;
    return this;
  }
  create() {
    return (
      <NGradientText {...this.attrs} {...this.props}>
        {{
          default: () => getSlotsDom(this.defaultSlot),
        }}
      </NGradientText>
    );
  }
}
